package cc.tuhaolicai.mt.user.mobile.tool;

import com.google.common.base.MoreObjects;
import org.asyou.mongo.wrapper.DateFromTo;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 分页用
 */
public class PageInfo implements Serializable {

    /**
     * 每页多少个数据
     */
    private int pageSize;

    private Map<String, Integer> sortMap;

    /**
     * 第几页(是0就是1)
     */
    private int pageIndex;
    private DateFromTo dateFromTo;

    public PageInfo() {
        this.pageIndex = 1;
        this.sortMap = new HashMap<>();
        this.pageSize = 20;
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("pageSize", pageSize)
                .add("sortMap", sortMap)
                .add("pageIndex", pageIndex)
                .add("dateFromTo", dateFromTo)
                .toString();
    }

    public int getPageSize() {
        return pageSize;
    }

    public PageInfo setPageSize(int pageSize) {
        this.pageSize = pageSize;
        return this;
    }

    public Map<String, Integer> getSortMap() {
        return sortMap;
    }

    public PageInfo setSortMap(Map<String, Integer> sortMap) {
        this.sortMap = sortMap;
        return this;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public PageInfo setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
        return this;
    }

    public DateFromTo getDateFromTo() {
        return dateFromTo;
    }

    public PageInfo setDateFromTo(DateFromTo dateFromTo) {
        this.dateFromTo = dateFromTo;
        return this;
    }
}
